package config.Strategy;

import com.baomidou.mybatisplus.generator.config.builder.Controller;
import com.baomidou.mybatisplus.generator.config.builder.Service;
import config.Config;
import config.StrategyConfig;
import org.apache.commons.lang3.StringUtils;

/**
 * @Description config.Strategy
 * @Author zhengzetao
 * @Date 2022/9/18 18:33
 */
public class ServiceConfig extends Config {

    final private static String GROUP = "StrategyConfig.Service";

    //superServiceClass(String)	设置 service 接口父类	com.baomidou.global.BaseService
    private String superServiceClass;
    //superServiceImplClass(String)	设置 service 实现类父类	com.baomidou.global.BaseServiceImpl
    private String superServiceImplClass;
    //formatServiceFileName(String)	格式化 service 接口文件名称	%sService
    private String formatServiceFileName;
    //formatServiceImplFileName(String)	格式化 service 实现类文件名称 %sServiceImp
    private String formatServiceImplFileName;

    private ServiceConfig(){
        super(GROUP);
        this.superServiceClass = getStr("superServiceClass");
        this.superServiceImplClass = getStr("superServiceImplClass");
        this.formatServiceFileName = getStr("formatServiceFileName");
        this.formatServiceImplFileName = getStr("formatServiceImplFileName");
    }

    public static void setting(Service.Builder builder){
        ServiceConfig config = new ServiceConfig();
        if(StringUtils.isNotBlank(config.superServiceClass)){
            builder.superServiceClass(config.superServiceClass);
        }
        if(StringUtils.isNotBlank(config.superServiceImplClass)){
            builder.superServiceImplClass(config.superServiceImplClass);
        }
        if(StringUtils.isNotBlank(config.formatServiceFileName)){
            builder.formatServiceFileName(config.formatServiceFileName);
        }
        if(StringUtils.isNotBlank(config.formatServiceImplFileName)){
            builder.formatServiceImplFileName(config.formatServiceImplFileName);
        }
    }
}
